package com.corpgovernment.travelstandard.loader;

import com.corpgovernment.travelstandard.entity.db.MbTravelStandardAirportTransfer;
import com.corpgovernment.travelstandard.mapper.MbTravelStandardAirportTransferMapper;
import com.ctrip.corp.obt.generic.utils.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.ArrayList;
import java.util.List;

/**
 * @author jhxue
 * @create 2022-05-12-17:56
 */
@Component
public class MbTravelStandardAirportTransferLoader {

	@Autowired
	private MbTravelStandardAirportTransferMapper mapper;

	public Long save(MbTravelStandardAirportTransfer entity) {
		if (entity == null) {
			return null;
		}
		boolean flag = mapper.insertSelective(entity) > 0;
		return flag ? entity.getId() : null;
	}

	public List<MbTravelStandardAirportTransfer> selectByOrgId(String orgId) {
		if (StringUtils.isBlank(orgId)) {
			return new ArrayList<>();
		}
		MbTravelStandardAirportTransfer record = new MbTravelStandardAirportTransfer();
		record.setOrgId(orgId);
		return mapper.select(record);
	}

	public MbTravelStandardAirportTransfer selectById(Long id) {
		if (id == null) {
			return null;
		}
		return mapper.selectByPrimaryKey(id);
	}

	public int updateById(MbTravelStandardAirportTransfer record) {
		if (record == null || record.getId() == null) {
			return 0;
		}
		return mapper.updateByPrimaryKey(record);
	}

	public boolean deleteById(Long tsId) {
		if (tsId == null) {
			return false;
		}
		return mapper.deleteByPrimaryKey(tsId) > 0;
	}
}
